<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script src="./axios.min.js"></script>
<script>
    //封装
    //instance随便命名
    let instance=axios.create({
        baseURL:`http://localhost:3000`,//集中配置请求头
        headers:{
            'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0aW1lIjoxNzQwNDU0NDE2MTMwLCJleHBpcmUiOjg2NDAwMDAwLCJpYXQiOjE3NDA0NTQ0MTZ9.uhJNKeShgbEY-nv9ucoNEkswEpsQ6Y2-ZaPMDsPYCl0'
        }
    })
    //使用分装后的
    instance.get('/fanji').then(result=>{
        console.log(result);
        alert(res.data.msg)//弹出,在请求结束后为用户明确提示
    })
    //post
    instance.post('/fanji',{list:[]}).then(result=>{
        console.log(result);
        alert(res.data.msg)//弹出,在请求结束后为用户明确提示
    })
</script>
</html>